package com.dupf.upms.rpc.api;

import com.dupf.upms.dao.model.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.util.List;
import java.util.Map;

/**
 * upms系统接口
 * Created by dupf on 2018/3/1.
 */
public interface UpmsApiService {

    /**
     * 根据用户id获取所拥有的权限(用户和角色权限合集)
     *
     * @param upmsUserId
     * @return
     */
    List<UpmsPermission> selectUpmsPermissionByUpmsUserId(Integer upmsUserId);

    /**
     * 根据用户id获取所拥有的权限(用户和角色权限合集)
     *
     * @param upmsUserId
     * @return
     */
    List<UpmsPermission> selectUpmsPermissionByUpmsUserIdByCache(Integer upmsUserId);

    /**
     * 根据用户id获取所属的角色
     *
     * @param upmsUserId
     * @return
     */
    List<UpmsRole> selectUpmsRoleByUpmsUserId(Integer upmsUserId);

    /**
     * 根据用户id获取所属的角色
     *
     * @param upmsUserId
     * @return
     */
    List<UpmsRole> selectUpmsRoleByUpmsUserIdByCache(Integer upmsUserId);

    /**
     * 根据角色id获取所拥有的权限
     *
     * @param upmsRoleId
     * @return
     */
    List<UpmsRolePermission> selectUpmsRolePermisstionByUpmsRoleId(Integer upmsRoleId);

    /**
     * 根据用户id获取所拥有的权限
     *
     * @param upmsUserId
     * @return
     */
    List<UpmsUserPermission> selectUpmsUserPermissionByUpmsUserId(Integer upmsUserId);

    /**
     * 根据条件获取系统数据
     *
     * @param upmsSystemExample
     * @return
     */
    List<UpmsSystem> selectUpmsSystemByExample(UpmsSystemExample upmsSystemExample);

    /**
     * 根据条件获取组织数据
     *
     * @param upmsOrganizationExample
     * @return
     */
    List<UpmsOrganization> selectUpmsOrganizationByExample(UpmsOrganizationExample upmsOrganizationExample);

    /**
     * 根据username获取UpmsUser
     *
     * @param username
     * @return
     */
    UpmsUser selectUpmsUserByUsername(String username);

    /**
     * 根据username获取UpmsUser常用信息
     *
     * @param username
     * @return
     */
    JSONObject selectUpmsUserInfoByUsername(String username);

    List<UpmsRole> getOperableRoles(Integer userId);

    List<UpmsUser> getOperableUserList(String userName, Integer orgId);

    List<UpmsUser> getOperableUserListByCache(String userName, Integer orgId);

    List<UpmsUser> getOrgUserList(Integer orgId);

    JSONObject getOperableUserListWithRole(String userName, Integer orgId, Integer offset, Integer limit);

    JSONArray getOperableListJson(String userName, Integer orgId);

    Integer createEmployee(UpmsUser upmsUser, Integer orgId, Integer roleId);

    /**
     * 写入操作日志
     *
     * @param record
     * @return
     */
    int insertUpmsLogSelective(UpmsLog record);

    /**
     * 发送验证码
     *
     * @param mobile
     * @return
     */
    boolean sendSmsCode(String mobile);

    /**
     * 校验验证码
     *
     * @param mobile
     * @param smsCode
     * @return
     */
    boolean verifySmsCode(String mobile, String smsCode);

    /**
     * 获取七牛云上传token
     *
     * @param userId
     * @param bucket
     * @param module
     * @return
     */
    Map<String, Object> getQiniuToken(String userId, String bucket, String module);

    /**
     * 直接上传网络图片
     *
     * @param url
     * @param bucket
     * @return
     */
    Map<String, Object> uploadUrlFile(String url, String bucket);


    List<UpmsUser> getUserListByUserIds(String userIds);

}
